#ifndef RTSPDECODESOFT_H
#define RTSPDECODESOFT_H

extern "C"{
    #include "libavcodec/avcodec.h"
    #include "libavformat/avformat.h"
    #include "libswscale/swscale.h"
    #include "libavdevice/avdevice.h"
    #include "libswresample/swresample.h"
    #include "libavutil/imgutils.h"
}
#include <iostream>

#include <QObject>
#include <QDebug>
#include <QImage>

//解码类
class RtspDecodeSoft : public QObject
{
private:
    AVFormatContext* formatContext = nullptr;//上下文
    AVCodecContext* codecContext = nullptr;//解码上下文
    AVStream* videoStream = nullptr;
    SwsContext* swsContext = nullptr;

public:
    RtspDecodeSoft(QObject *parent = nullptr);
    ~RtspDecodeSoft();

    bool open(const std::string& url); // 打开RTSP流并初始化解码器。
    void close();//关闭
    bool decode_one_frame(AVPacket *packet,uint8_t *rgbFrame_dst,int *dstStride);//输入一包输出解码一帧
    bool decode_one_frame_toQImage(AVPacket *packet,QImage& img);
    bool decode_one_packet(AVPacket *packet);//返回一包数据
};




#endif
